package Imp.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Slf4j
@Configuration
public class mqConfig {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void init() {
        rabbitTemplate.setReturnsCallback(returned -> {
            log.info("消息监听开始");
            log.info("Returned exchage: {}", returned.getExchange());
            log.info("Returned message: {}", returned.getMessage());
            log.info("Returned routingkey: {}", returned.getRoutingKey());
            log.info("Returned replycode: {}", returned.getReplyCode());
            log.info("Returned replytext: {}", returned.getReplyText());
        });
    }
}
